package co.yixiang.yshop.module.crm.dal.mysql.crmcloudcall;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.crm.dal.dataobject.crmcloudcall.CrmCloudcallDO;
import co.yixiang.yshop.module.crm.dal.dataobject.crmcustomer.CrmCustomerDO;
import co.yixiang.yshop.module.system.dal.dataobject.user.AdminUserDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.crm.controller.admin.crmcloudcall.vo.*;

/**
 * 云呼坐席管理 Mapper
 *
 * @author yshop
 */
@Mapper
public interface CrmCloudcallMapper extends BaseMapperX<CrmCloudcallDO> {

    default PageResult<CrmCloudcallRespVO> selectPage(CrmCloudcallPageReqVO reqVO) {
        return selectJoinPage(reqVO, CrmCloudcallRespVO.class,new MPJLambdaWrapper<CrmCloudcallDO>()
                .selectAll(CrmCloudcallDO.class)
                .selectAs(AdminUserDO::getNickname,CrmCloudcallRespVO::getAdminName)
                .leftJoin(AdminUserDO.class, AdminUserDO::getId, CrmCloudcallDO::getAdminId)
                .likeIfExists(AdminUserDO::getNickname, reqVO.getAdminName())
                .eqIfExists(CrmCloudcallDO::getFromExten, reqVO.getFromExten())
                .orderByDesc(CrmCloudcallDO::getId));
    }

    default PageResult<CrmCloudcallDO> selectPage2(CrmCloudcallPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CrmCloudcallDO>()
                .eqIfPresent(CrmCloudcallDO::getAdminId, reqVO.getAdminName())
                .eqIfPresent(CrmCloudcallDO::getFromExten, reqVO.getFromExten())
                .eqIfPresent(CrmCloudcallDO::getExtenType, reqVO.getExtenType())
                .eqIfPresent(CrmCloudcallDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CrmCloudcallDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CrmCloudcallDO::getId));
    }

}